<template>
  <div class="app-bg auto">
    <div class="auto" style="background:#108ADD;text-align:center; padding:10px 0px;color:#FFF;font-size: 18px;">
      博能燃气手机抄表
    </div>
      <div class="row app-input">
        <label class="col-xs-4 control-label text-left">户号</label>
        <input class="col-xs-8" v-model="model.f_userinfo_id" placeholder="请输入用户编号">
      </div>
      <div class="row app-input">
        <label class="col-xs-4 control-label text-left">姓名</label>
        <input class="col-xs-8" v-model="model.f_user_name" placeholder="请输入用户姓名">
      </div>
      <div class="app-btn">
      <button type="button" name="button" class="btn btn-primary"  @click="this.$back()">
        <span  class="glyphicon glyphicon-remove-circle" style="margin-right: 15px;"></span>返回
      </button>
      <button type="button" name="button" class="btn btn-primary"  @click="search()">
        <span  class="glyphicon glyphicon-zoom-in" style="margin-right: 15px;"></span>查询
      </button>
    </div>
      <!-- <div class="row app-btn" style="margin-bottom: -5px;">
        <button class="btn btn-primary col-xs-6" @click="search()"><span class="glyphicon glyphicon-zoom-in" style="margin-right: 20px;"></span>查询</button>
      </div> -->

    <div v-for='row in user' class="app-list">
      <div class="row" style="color: #00B9F1;">
        <span class="col-xs-3">户号：</span><span class="col-xs-3">{{row.f_userinfo_id}}</span>
        <span class="col-xs-3">姓名：</span><span class="col-xs-3">{{row.f_user_name}}</span>
      </div>
      <div class="row">
        <span class="col-xs-4">账户余额：</span><span class="col-xs-8">{{row.f_balance}}</span>
      </div>
      <div class="row">
        <span class="col-xs-4">用户电话：</span><span class="col-xs-8">{{row.f_user_phone}}</span>
      </div>
      <div class="row">
        <span class="col-xs-4">用户地址：</span><span class="col-xs-8">{{row.f_address}}</span>
      </div>
    </div>
  </div>
</template>

<script>
import co from 'co'
import appData from '../../../src/components/appData'
import config from '../../../src/components/config'
let usersearch = function * (self) {
  // config.resultUrl +
  yield self.$post(config.resultUrl + 'rs/sql/usersearch', {data: {f_user_name:self.model.f_user_name,f_userinfo_id:self.model.f_userinfo_id}},
   {resolveMsg: null, rejectMsg: null})
  .then ((res)=> {
    self.user = res.data
  })
  .catch ((res)=> {
    self.$showMessage('获取用户数据失败，请查看你输入的查询信息')
  })
}
export default {
  props: ['userinfo'],
  title:'用户信息',
  data () {
    return {
      model: {
        f_userinfo_id: '',
        f_user_name: ''
      },
      user: []
    }
  },
  methods: {
    search () {
    if (this.model.f_user_name !=='' || this.model.f_userinfo_id !== '') {
      let gen = usersearch(this)
      return co(gen)
    } else {
      this.$showMessage('请输入任意查询条件，确保信息准确性')
    }
    }
  }
}
</script>
